/**   
 * @Title: trackingRecordDetailCommunicater.java 
 * @Package: com.esun.rabbit2.communicaters.trackingrecord 
 * @Description: (追号记录详情接口) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-7-27 下午05:51:18  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.trackingrecord;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.TrackingRecordDetailInfo;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.log.EDebug;

/**
 * @ClassName: trackingRecordDetailCommunicater
 * @Description: (追号记录详情接口)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-7-27 下午05:51:18
 */
public class TrackingRecordDetailCommunicater extends ServerCommunicater {

	private String USERSESSION = UserInfo.getUserInfo().getUserSession();
	private String msgServer;

	public void setMsgServer(String str) {
		this.msgServer = str;
	}

	public String getMsgServer() {
		return msgServer;
	}

	public boolean isGetTrackingRecordDetail(String lotid, String pid) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		boolean isSucceed = false;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_TRACKING_DETAIL));
		list.add(mapItem(BussinessCode.PASER_CK, USERSESSION));
		list.add(mapItem(Key.KEY_LOTID, lotid));
		list.add(mapItem(Key.KEY_PROID, pid));

		super.getServerResponse(list, true);
		setMsgServer(super.getServerMsg());
		EDebug.o(this, super.getServerMsg());
		if (super.getState() == 100) {
			isSucceed = true;
		}

		return isSucceed;
	}

	public TrackingRecordDetailInfo getDetailInfo() {
		TrackingRecordDetailInfo infoTemp = new TrackingRecordDetailInfo();
		infoTemp.setUserName(super.getResult().get(Key.KEY_USERNAME));
		infoTemp.setMainID(super.getResult().get(Key.KEY_MPID));
		infoTemp.setAddTime(super.getResult().get(Key.KEY_ADDTIME).replace(Config.CHAR_JINGHAO, Config.CHAR_SPACE));
		infoTemp.setAllMoney(super.getResult().get(Key.KEY_ALLMONEY));
		infoTemp.setFinishMoeny(super.getResult().get(Key.KEY_SUCMONEY));
		infoTemp.setTotalNum(super.getResult().get(Key.KEY_EXPNUM));
		infoTemp.setFinishNum(super.getResult().get(Key.KEY_SUCNUM));
		infoTemp.setIsStop(super.getResult().get(Key.KEY_ISSTOP));
		infoTemp.setContent(super.getResult().get(Key.KEY_CODE));
		infoTemp.setMainState(super.getResult().get(Key.KEY_MAINSTATE));

		for (int i = 0; i < super.getListResult().size(); i++) {
			infoTemp.setExpect(super.getListResult().get(i).get(Key.KEY_EXP));
			infoTemp.setOpenCode(super.getListResult().get(i).get(Key.KEY_OPENCODE));
			infoTemp.setChildID(super.getListResult().get(i).get(Key.KEY_ID));
			infoTemp.setchildState(super.getListResult().get(i).get(Key.KEY_CSTATE));
			infoTemp.setGetMoney(super.getListResult().get(i).get(Key.KEY_GETMONEY));
			infoTemp.setPID(super.getListResult().get(i).get(Key.KEY_PID));

		}
		return infoTemp;
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
